﻿using ERPSystem.Common.DTO;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RBACCommon.API.Command.Permissions;

namespace RBACCommon.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RBACsController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<RBACsController> _logger;
        private readonly IConfiguration configuration;
        public RBACsController(IMediator mediator, ILogger<RBACsController> logger, IConfiguration configuration)
        {
            this.mediator = mediator;
            _logger = logger;
            this.configuration = configuration;
        }
        /// <summary>
        /// 权限列表
        /// </summary>
        /// <param name="enm"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultPage<RolesPermissionListDto>> PermissionList([FromQuery] PermissionListCommon enm)
        {
            var list = await mediator.Send(enm);
            return list;
        }
        /// <summary>
        /// 获取权限列表级联
        /// </summary>
        /// <param name="enm"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result<List<PermissionCascaderDto>>> GetPermissionCascaderList()
        {
            var list = await mediator.Send(new PermissionCascaderCommon());
            return list;
        }
    }
}
